#pragma once

#include "Resource.h"

class CTestLibDlg : public CDialogImpl<CTestLibDlg>
{
public:
	CTestLibDlg();

	enum { IDD = IDD_TESTLIB_DLG };

	BEGIN_MSG_MAP(CTestLibDlg)
		MESSAGE_HANDLER(WM_INITDIALOG, OnInitDialog)
		MESSAGE_HANDLER(WM_CLOSE, OnClose)
		COMMAND_ID_HANDLER(IDC_BUTTON1, OnBtnClick1)
		COMMAND_ID_HANDLER(IDC_BUTTON2, OnBtnClick2)
		COMMAND_ID_HANDLER(IDC_BUTTON3, OnBtnClick3)
		COMMAND_ID_HANDLER(IDC_BUTTON4, OnBtnClick4)
		COMMAND_ID_HANDLER(IDC_BUTTON5, OnBtnClick5)
		COMMAND_ID_HANDLER(IDC_BUTTON6, OnBtnClick6)
	END_MSG_MAP()

private:
	LRESULT OnInitDialog(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL &bHandled);
	LRESULT OnClose(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL &bHandled);
	LRESULT OnBtnClick1(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL &bHandled);
	LRESULT OnBtnClick2(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL &bHandled);
	LRESULT OnBtnClick3(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL &bHandled);
	LRESULT OnBtnClick4(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL &bHandled);
	LRESULT OnBtnClick5(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL &bHandled);
	LRESULT OnBtnClick6(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL &bHandled);
	void OnFinalMessage(HWND) override;
	void OnUiTimer() const;
	void OnTpTimer() const;

	CUiTimer m_uiTimer;
	CTpTimer m_tpTimer;

	void TestTask1(int nDelay) const;
	static Task<> TestAsync1();
	static Task<int> MyAsync1(bool bAll);
	static Task<std::string> MyAsync2();
	static Task<int&> MyAsync3();
	static Task<> TestAsync2();
	static Task<> TestAsync3(DWORD dwMainThreadId);
	static Task<> TestCaptureThread();
	static Task<> TestWrapFnAsAsync();
	static Task<> TestAsyncFile();
	static Task<> TestAsyncFile2();

	static int m_nValue;
};
